<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0 auto;
        }

        body {
            background-color: #ddd;
        }

        .box {
            width: 200px;
            margin-top: 20px;
            background-color: #ddd;
        }

        .box ul {
            border: 1px solid #bbb;
            list-style: none;
        }

        .box ul span {
            display: block;
            line-height: 40px;
            border-top: 1px solid #bbb;
            border-bottom: 1px solid #bbb;
            cursor: pointer;
            padding-left: 20px;
        }

        li p {
            border-bottom: 1px solid #bbb;
            background-color: white;
            line-height: 30px;
            padding-left: 20px;
            cursor: pointer;
            color: #bbb;
        }

        li p {
            display: none;
            transition: all .4s;
        }

        li p:hover {
            background-color: yellowgreen;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li>
                <span>哲学</span>
                <p>1</p>
                <p>2</p>
                <p>3</p>
                <p>4</p>
            </li>
            <li>
                <span>经济学</span>
                <p>1</p>
                <p>2</p>
                <p>3</p>
                <p>4</p>
            </li>
            <li>
                <span>法学</span>
                <p>1</p>
                <p>2</p>
                <p>3</p>
                <p>4</p>
            </li>
            <li>
                <span>教育学</span>
                <p>1</p>
                <p>2</p>
                <p>3</p>
                <p>4</p>
            </li>
            <li>
                <span>工学</span>
                <p>1</p>
                <p>2</p>
                <p>3</p>
                <p>4</p>
            </li>
        </ul>
    </div>

    <script src="./jquery.js"></script>
    <script>

        $('li').on('click', function () {
            //jQuery特性：隐式迭代
            //jQuery特性：链式编程，在于一个方法返回的是一个jQuery对象，既然是jQuery对象就可以继续点出jQuery的方法来
            $(this).children('p').show().parent().siblings('li').children('p').hide();

            //li   //li里面p   //显示  //p的父级li //除了自己的所有li //里面的p  //隐藏

                         //show()返回当前元素p 
        })

    </script>
</body>

</html>